<?xml version="1.0" encoding="UTF-8"?>
<!-- Ogni foglio di stile deve deve condensare le variabilità nei parametri iniziali.
        Questo permette di poter rendere omogenee, e quindi semplici, le modifiche
        a fogli di stile differenti-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:param name="SortingField1" select="expression/edate"/>
    <xsl:param name="SortingField2" select="expression/edate"/>
    <xsl:param name="ordinamento" select="ascending"></xsl:param>
    
    <xsl:template match="/">
        <response>
        <xsl:choose>
        	<xsl:when test="$ordinamento='ascending'">
           <xsl:apply-templates select="response/metadati" >
               <xsl:sort select="$SortingField1" order="ascending" />
               <xsl:sort select="$SortingField2" order="ascending" />
           </xsl:apply-templates>
           </xsl:when>
           <xsl:otherwise>
           	<xsl:apply-templates select="response/metadati" >
               <xsl:sort select="$SortingField1" order="descending" />
               <xsl:sort select="$SortingField2" order="descending" />
           </xsl:apply-templates>
           </xsl:otherwise>
        </xsl:choose>   
        </response>
    </xsl:template>
    <xsl:template match="metadati">
       <xsl:copy-of select="." />
    </xsl:template>
</xsl:stylesheet>
